<#include "/admin/common/head.html"/>
			<!-- /section:basics/sidebar -->
			<div class="main-content">
				<div class="main-content-inner">
					<!-- /section:basics/content.breadcrumbs -->
					<div class="page-content">
						<div class="page-header">
							<h1>
								首页
								<small>
									<i class="ace-icon fa fa-angle-double-right"></i>
									图书管理
								</small>
							</h1>
						</div><!-- /.page-header -->
						  <div class="row" id="grid-condition-bed">
                <div class="col-xs-3">
                    <div>
                        <span>书名：<input type="text" id="bname" name="bname" onclick="WdatePicker()"></span>
                    </div>
                </div>
                <div class="col-xs-3">
                    <div>
                        <span>类别：<select id="categories" name="cid" style="width:60%;"></select></span>
                    </div>
                </div>
                <div class="col-xs-4">
                    <div>
                        <span><button class="btn btn-xs btn-info" type="button" onclick="query()">查询</button></span>
                    </div>
                </div>
            </div>

						<div class="row">
                    	<@p.table id="book" url="/book/getPager" addfunc="optAdd" multiselect=false height=250>
                    	<@p.column name="bid" title="bid" width=0 hidden=true/>
                    	<@p.column name="bname" title="书名" width=100/>
                    	<@p.column name="price" title="价格" />
                    	<@p.column name="author" title="作者"/>
                    	<@p.column name="cname" title="所属类别"/>
                    	<@p.column name="sellcount" title="销售数量"/>
                    	<@p.column name="recommend" title="推荐书籍" buttons="displayRecommend" width=100/>
                    	<@p.column name="opt" title="操作" width=100 buttons="displayButtons"/>
                		</@p.table>
            		</div>
					</div><!-- /.page-content -->
				</div>
			</div><!-- /.main-content -->
		<#include "/admin/common/foot.html"/>
		<script type="text/javascript">
		jQuery(function($) {
	    	$( "#tabs" ).tabs();
	    	$.get("${baseUrl}/category/list",{},function(data){
	    		var html="<option value=''>请选择</option>";
	    		$.each(data,function(i,category){
	    			html+="<option value='"+category.cid+"'>"+category.cname+"</option>"
	    		});
	    		$("#categories").append(html);
	    	});
		});
		 function displayButtons(cellvalue, options, rowObject){
		        return"<a class='green' title=\"修改书籍\" href='javascript:optEdit(\""+rowObject.bid+"\")'><i class='ace-icon fa fa-pencil bigger-130'></i></a>&nbsp;&nbsp;"+
		        "<a class='red' title=\"删除书籍\" href='javascript:optDel(\""+rowObject.bid+"\")'><i class='ace-icon fa fa-trash-o bigger-130'></i></a>"
		 }
		 function displayRecommend(cellvalue, options, rowObject){
			 if(cellvalue=="1"){
				 return "是";
			 }else{
				 return "否";
			 }
		 }
		 function optAdd(){
		        $.dialog("${baseUrl}/book/admin/to_add","新增","800px","500px");
		 }
		 function optDel(bid){
		        $.confirm("确认删除？", function(){
		            $.ajax({
		                type:"POST",
		                url:"${baseUrl}/book/admin/remove",
		                data:'bid='+bid,
		                cache:false,
		                async:false,
		                dataType:"json",
		                success: function(dataResult){
		                    alertMsg(dataResult.msg.msgText,dataResult.msg.msgStatus);
		                    optReloadGrid();
		                }
		            });
		        });
		    }
		 function optEdit(bid){
			 $.dialog("${baseUrl}/book/admin/to_edit?bid="+bid,"修改","800px","500px");
		 }
		 function query(){
		        optReloadGrid();
		 }
		</script>